Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optionally treat digits as capitals when converting to snake case #417

Merged
merged 3 commits into from
Oct 26, 2023

Conversation

bjeffrey92
Copy link
Contributor

Thanks for creating this, it's very useful

However, I discovered when using your package that I needed a slight variant on the to_snake() function. Specifically, I needed a camel case string like myVariable2 to be converted to my_variable_2 rather than my_variable2, so I tweaked your function to allow this. (The default behaviour remains the same so this should be backwards compatible)

Figured I should offer it back in case it is of use to other people. Feel free to take or leave it

Copy link
Owner

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I like this idea. I debated the best way to handle numbers, it will be good to have both options.

Will you also add a test to test_camel_converter.py for this? You could either tweak the test_to_snake test or test this one in its own test, either way would be fine.

camel_converter/__init__.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (17035e5) 100.00% compared to head (0657a9a) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #417   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           97       101    +4     
=========================================
+ Hits            97       101    +4     
Files Coverage Δ
camel_converter/__init__.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Co-authored-by: Paul Sanders <psanders1@gmail.com>
@bjeffrey92
Copy link
Contributor Author

Thanks, I like this idea. I debated the best way to handle numbers, it will be good to have both options.

Will you also add a test to test_camel_converter.py for this? You could either tweak the test_to_snake test or test this one in its own test, either way would be fine.

OK, I will update the test suite

@sanders41 sanders41 added the enhancement New feature or request label Oct 26, 2023
@bjeffrey92
Copy link
Contributor Author

Thanks, I like this idea. I debated the best way to handle numbers, it will be good to have both options.
Will you also add a test to test_camel_converter.py for this? You could either tweak the test_to_snake test or test this one in its own test, either way would be fine.

OK, I will update the test suite

This is done

Copy link
Owner

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@sanders41 sanders41 merged commit 066006c into sanders41:main Oct 26, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants